# ADMIN: Used to add/remove/edit countries

class Admin::CountriesController < Admin::BaseController
  def index
    @countries = Country.paginate :page=>params[:page]
  end

  def edit
    @country = Country.find params[:id]
  end

  def destroy
    @country = Country.find params[:id]
    @country.destroy
    flash[:notice] = "country was deleted."
    redirect_to admin_countries_path
  end

  def update
    @country = Country.find params[:id]
    if @country.update_attributes params[:country]
      flash[:notice] = "Country was updated successful."
      redirect_to admin_countries_path
    else
      render :partial=>"edit"
    end
  end

  def create
    @country = Country.new params[:country]
    if @country.save
      flash[:notice] = "Country was created."
      redirect_to admin_countries_path
    else
      render :partial=>"new"
    end
  end

  def new
    @country = Country.new
  end
end
